package com.gz.moreaseManager.filter;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

public class WebXssFilter implements Filter {

	private static final Log logger = LogFactory.getLog(WebXssFilter.class);

	@Override
	public void init(FilterConfig arg0) {
		/**
		 * 初始化入口
		 */
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		try {
			XssWrapper xssRequest = new XssWrapper((HttpServletRequest) request);
			chain.doFilter(xssRequest, response);
		} catch (IOException | ServletException e) {
			logger.error("Xss过滤器，包装request对象失败", e);
			chain.doFilter(request, response);
		}
	}

	@Override
	public void destroy() {
		/**
		 * 注销释放
		 */
	}
}